Introduction
This R Markdown report enables to analyze time series from Yahoo Finance of userâs choice. The report takes user input and creates tables, plots and tests based on that input and allows to thoroughly analyze different quotes and time spans without interfering with the code.
This version of report provides several tech and motor companies to choose from, however, should one want to analyze another, he/she should add the abbreviation and companyâs full name to the parameterâs choice list and dictionary and the report would be good to go. Default time range spans back a thousand days from the day of running the report. Should the multiple choice for the quotes be left empty, then as default, all prices are included in the analysis. Last parameter determines the forecast period in days.
Data
Gathering of the time series data is performed via getSymbols function provided in quantmod package. More information about the package can be found here. Data used in this particular report is characterized by following parameters:
- Company name:
General Motors Company - Company abbreviation:
GM - Time span:
2018-09-04-2021-05-31 - Quotes:
High - Simulation paths:
10
Below you can see a glimpse of the first and last few observations of the data of your choice.
| Date | GM.High |
|---|---|
| 2021-05-28 | 59.99 |
| 2021-05-27 | 60.72 |
| 2021-05-26 | 58.17 |
| 2021-05-25 | 58.17 |
| 2021-05-24 | 57.20 |
| 2021-05-21 | 58.78 |
| Date | GM.High |
|---|---|
| 2018-09-11 | 33.96 |
| 2018-09-10 | 34.25 |
| 2018-09-07 | 34.36 |
| 2018-09-06 | 35.27 |
| 2018-09-05 | 35.60 |
| 2018-09-04 | 36.00 |
Descriptive statistics
General
Below you can find a handful of descriptive statistics regarding the columns specified during knitting. Maximum price recorded for General Motors Company during 2018-09-04 - 2021-05-31 period was $63.44, while the minimum was $9.29.
| Variable | Mean | Std. | Min | 1st quartile | Median | 3rd quartile | Max |
|---|---|---|---|---|---|---|---|
| data | 37.71 | 9.29 | 18.56 | 32.94 | 36.72 | 39.72 | 63.44 |
Log returns
This chapter provides insight on the log returns of selected prices. Log returns are more widely used in finance than simple returns for a number of reasons, one being that prices are assumed to be log-normally distributed. That is not always the case as can be seen on the graphs below. Nevertheless, this assumption results in logarithms of prices to be normally distributed. More information on this topic can be found here.
Each of the graphs below represents a histogram of log returns of certain price, as well as kernel density estimate (white line). It is plotted agains a normal distribution (red line) with mean and standard deviation calculated separately for each graph.
GM.High
Plotting
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Stationarity analysis
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Trend
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.4253 -0.4555 -0.0342 0.4004 3.7144
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.0501883 0.0691598 -0.726 0.468
## z.lag.1 -0.9855419 0.0525323 -18.761 <2e-16 ***
## tt 0.0002482 0.0001744 1.423 0.155
## z.diff.lag 0.0476661 0.0384814 1.239 0.216
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.902 on 682 degrees of freedom
## Multiple R-squared: 0.4713, Adjusted R-squared: 0.469
## F-statistic: 202.7 on 3 and 682 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -18.7607 117.3215 175.9815
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2 6.09 4.68 4.03
## phi3 8.27 6.25 5.34
According to the ADF test the series are integrated of order 1, or in other words have become stationary after 1 differentiation(s). The program differentiated the series until it found order where value of test-statistic: -18.7606736 is smaller than tau3 5pct: -3.41.
Drift
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.4109 -0.4516 -0.0622 0.4067 3.7760
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.03510 0.03451 1.017 0.309
## z.lag.1 -0.97982 0.05242 -18.693 <2e-16 ***
## z.diff.lag 0.04496 0.03846 1.169 0.243
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9027 on 683 degrees of freedom
## Multiple R-squared: 0.4698, Adjusted R-squared: 0.4682
## F-statistic: 302.6 on 2 and 683 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -18.6926 174.7082
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.43 -2.86 -2.57
## phi1 6.43 4.59 3.78
According to the ADF test the series are integrated of order 1, or in other words have become stationary after 1 differentiation(s). The program differentiated the series until it found order where value of test-statistic: -18.6926439 is smaller than tau3 5pct: -2.86.
None
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression none
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.3730 -0.4167 -0.0267 0.4380 3.8106
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## z.lag.1 -0.97703 0.05235 -18.665 <2e-16 ***
## z.diff.lag 0.04365 0.03844 1.136 0.257
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9027 on 684 degrees of freedom
## Multiple R-squared: 0.469, Adjusted R-squared: 0.4674
## F-statistic: 302 on 2 and 684 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -18.6645
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau1 -2.58 -1.95 -1.62
According to the ADF test the series are integrated of order 1, or in other words have become stationary after 1 differentiation(s). The program differentiated the series until it found order where value of test-statistic: -18.6645212 is smaller than tau3 5pct: -1.95.
Simulation
ARMA(1,1)-GARCH(1,1)
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.